/**
 * @Copyright：<a href="http://www.wisesoft.net.cn">四川川大智胜系统集成有限公司</a>
 * @Author: <a href="mailto:fxsen@foxmail.com">Fxsen</a>
 * @CreateTime: 2022年08月11日  10:07
 */
package com.fxsen.commons.utils;

import cn.hutool.core.util.ObjectUtil;
import com.fxsen.commons.core.base.result.ResponseStatus;
import com.fxsen.commons.core.exception.BusinessException;
import org.hibernate.validator.internal.constraintvalidators.hv.EmailValidator;

/**
 * 参数验证工具
 *@Author: <a href="mailto:fxsen@foxmail.com">Fxsen</a>
 *@CreateTime: 2022年08月11日  10:07
 */
public class ValidationUtils {
    /**
     * 验证空
     */
    public static void isNull(Object obj, String entity, String parameter , Object value){
        if(ObjectUtil.isNull(obj)){
            String msg = entity + " 不存在: "+ parameter +" is "+ value;
            throw new BusinessException(ResponseStatus.VALID_EXCEPTION.bCode,msg);
        }
    }
    /**
     * 验证是否为邮箱
     */
    public static boolean isEmail(String email) {
        return new EmailValidator().isValid(email, null);
    }
}
